<template>
  <div class="mine-wrapper">
    <div class="mine-header">
      <div class="left">
        <van-image
          round
          width="100%"
          height="100%"
          fit="cover"
          src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
        />
      </div>
      <div class="right" @click="handleGoCenter">
        <div class="title">{{ userInfo.realName }}</div>
        <div class="sub-title">
          <van-space>
            <div>部门</div>
            <div>{{ userInfo.departments?.join(',') }}</div>
          </van-space>
        </div>
        <div class="sub-title">{{ userInfo.phone || userInfo.account }}</div>
      </div>
    </div>
    <div class="mine-card">
      <div class="card-title">统计信息</div>
      <UserData></UserData>
    </div>

    <div class="mine-card">
      <div class="card-title">常用功能</div>
      <NormalItem></NormalItem>
    </div>

    <div class="mine-card">
      <div class="card-title">全部功能</div>
      <AllItem></AllItem>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { useRouter } from 'vue-router';
  import { useUserStore } from '@/store/index';
  import NormalItem from './components/NormalItem/index.vue';
  import AllItem from './components/AllItem/index.vue';
  import UserData from './components/UserData/index.vue';

  const userInfo = useUserStore();
  const router = useRouter();

  const handleGoCenter = () => {
    router.push({
      name: 'UserCenter',
    });
  };
</script>

<style lang="less" scoped>
  .mine-wrapper {
    padding: 20px;
    width: 750px;
    .mine-header {
      margin-bottom: 30px;
      display: flex;
      width: 100%;
      .left {
        margin-right: 24px;
        flex-shrink: 0;
        width: 120px;
        height: 120px;
      }
      .right {
        width: 100%;
        flex-shrink: 1;
        .title {
          margin-bottom: 16px;
          font-size: 16px;
          font-weight: bold;
        }
        .sub-title {
          margin-bottom: 8px;
          font-size: 12px;
          color: #999;
        }
      }
    }

    .mine-card {
      margin-bottom: 30px;
      padding: ;
      background: #fff;
      .card-title {
        padding: 24px;
        font-weight: bold;
        color: #333;
      }
      .card-row {
        width: 100%;
        display: flex;
        justify-content: space-between;
      }

      .card-item {
        width: 25%;
        display: flex;
        flex-direction: column;
        align-items: center;

        .top {
          margin-bottom: 8px;
          font-size: 12px;
          color: #999;
        }
        .bottom {
          align-items: center;
          display: flex;
          .num {
            margin-right: 8px;
            font-size: 18px;
            font-weight: bold;
          }
          .unit {
            transform: translateY(2px);
            font-size: 12px;
          }
        }
      }

      .fun-card-row {
        display: flex;
        flex-wrap: wrap;
      }

      .fun-card-item {
        margin-bottom: 30px;
        width: 25%;
        display: flex;
        flex-direction: column;
        align-items: center;
        .top {
          margin-bottom: 4px;
          text-align: center;
          font-size: 32px;
        }
        .bottom {
          text-align: center;
          font-size: 12px;
        }
      }
    }
  }
</style>
